package com.company;

import java.util.LinkedList;
import java.util.List;

/**
 * @date : 2023-03-09 上午10:00
 * -Xms4g -Xmx4g
 * 达不到数组最大上界，出现OOM
 * Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
 * 	at java.lang.Long.valueOf(Long.java:840)
 * 	at com.company.P043_LinkedListMaxSize.main(P043_LinkedListMaxSize.java:17)
 *
 * 	Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
 * 	at java.util.LinkedList.linkLast(LinkedList.java:142)
 * 	at java.util.LinkedList.add(LinkedList.java:338)
 * 	at com.company.P043_LinkedListMaxSize.main(P043_LinkedListMaxSize.java:20)
 */

public class P043_LinkedListMaxSize {

    public static void main(String[] args) {
        List<Long> list = new LinkedList<>();
        for (long i = 0; i < Long.MAX_VALUE; i++) {
            list.add(i);
        }
    }
}
